package com.uenpay.im.ui.old.activity.area;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.uenpay.im.R;

import java.util.ArrayList;


/**
 * @author SL
 * @created 2016-1-28 下午13:25:24
 * @copyRight http://www.qiyunxin.com
 * @function 地区适配器
 */
public class AreaAdapter extends BaseAdapter {

	private LayoutInflater mLayoutInflater;
	public ArrayList<AreaEntity> arrayList = new ArrayList<AreaEntity>();

	public AreaAdapter(Context _Context, ArrayList<AreaEntity> _arrayList) {
		mLayoutInflater = LayoutInflater.from(_Context);
		arrayList = _arrayList;
	}

	@Override
	public int getCount() {
		return arrayList == null ? 0 : arrayList.size();
	}

	@Override
	public Object getItem(int arg0) {
		return arrayList == null ? null : arrayList.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		AreaViewHodler areaViewHodler = null;
		AreaEntity mAreaEntity = arrayList.get(arg0);
		if (arg1 == null) {
			areaViewHodler = new AreaViewHodler();
			arg1 = mLayoutInflater.inflate(R.layout.item_area_layout, arg2,false);
			areaViewHodler.areaTv = (TextView) arg1.findViewById(R.id.area_tv);
			arg1.setTag(areaViewHodler);
		} else {
			areaViewHodler = (AreaViewHodler) arg1.getTag();
		}
		areaViewHodler.areaTv.setText(mAreaEntity.area);
		return arg1;
	}

	public class AreaViewHodler {
		private TextView areaTv;
	}
}
